package org.dicker.api;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dicker.biz.UserBiz;
import org.dicker.biz.impl.UserBizImpl;
import org.dicker.entity.UserInfo;
import org.lanqiao.mvc.entity.YockMvcAnnotation.Controller;
import org.lanqiao.mvc.entity.YockMvcAnnotation.RequestMapping;
import org.lanqiao.mvc.entity.YockMvcAnnotation.RequestParam;
import org.lanqiao.mvc.entity.YockMvcAnnotation.ResponseBody;

import cn.hutool.json.JSONUtil;

@Controller("/userapi")
public class UserApi {

	private UserBiz userBiz=new UserBizImpl();
	
	/**
	* showdoc
	* @catalog 用户管理模块
	* @title 查询指定id的用户信息
	* @description 这是一个查询指定id的用户信息的接口
	* @method post
	* @url http://192.168.10.6:8080/big-birds/userapi/user_infoapi.do
	* @param wx_openid 必选String 微信id
	* @return {"user_id":1,"phone":"12312312312","user_name":"sadsad","user_img":"sadas.jsp"}
	* @return_param user_id int 用户id
	* @return_param phone String 用户手机
	* @return_param user_name String 用户名称
	* @return_param user_img String 用户头像
	* @remark 这里是备注信息
	*/
	@RequestMapping(value = "/user_infoapi.do")
	@ResponseBody
	public String indexinfo(
			HttpServletRequest req,
			HttpServletResponse res,
			@RequestParam(name = "wx_openid") String wx_openid)
					throws Exception{
		
	 	UserInfo uInfo = userBiz.selectUserid(wx_openid);
		
		String jsonStr = JSONUtil.toJsonStr(uInfo);
		res.setCharacterEncoding("utf-8");
		res.setContentType("text/json; charset=UTF-8");
				
		return jsonStr;
	}
	
}
